/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package org.sbbs.demo.entity.enumtype;

import jakarta.persistence.AttributeConverter;

/**
 *
 * @author jenkins
 */
//@Converter
public class GenderConverter
        implements AttributeConverter<Gender, Character> {

    @Override
    public Character convertToDatabaseColumn(Gender value) {
        if (value == null) {
            return null;
        }

        return value.getCode();
    }

    @Override
    public Gender convertToEntityAttribute(Character value) {
        if (value == null) {
            return null;
        }

        return Gender.fromCode(value);
    }
}
